package leetcode.new_wrold;

public class T11 {
    public int maxArea(int[] height) {
        int max = 0;
        int left = 0;
        int right = height.length-1;

        while (left!=right){
            int temp;
            if (height[left]>=height[right]){
                temp = height[right]*(right-left);
                right--;
            }else {
                temp = height[left]*(right-left);
                left++;
            }
            if (temp>max){
                max = temp;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        T11 t11 = new T11();
        int maxArea = t11.maxArea(new int[]{4,3,2,1,4});
        System.out.println(maxArea);
    }
}

